import logging
import redis


class Config(object):
    # 配置数据库
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1/zhudachao'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 当请求结束时,TEARDOWN会自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    # 配置redis
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # 配置密钥
    """import os
    import base64
    base64.b64encode(os.urandom(32))
    """
    SECRET_KEY = 'aj9MuxEnRH9qLkeKRdyqSTDg60VD7XuG1yZFeEA2tp8='
    # 配置Flask—Session扩展
    SECRET_TYPE = 'redis'
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)

    SESSION_USE_SIGNER = True
    PERMANENT_SESSION_LIFETIME = 86400 * 7

    DEBUG = True


class DevelopmentConfig(Config):
    """开发模式下的配置"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING
